// 短信日志管理
<template>
  <div class="app-container">
  <el-card class="box-card" shadow="never" style="border:0px;">
      <div slot="header" style="color:#303133;font-size:14px;font-weight:bold;">
        <span>短信日志</span>
      </div>
    <div class="filter-container">
      <div class="left">
        <el-form :inline="true" class="demo-form-inline" size="medium" label-position="right">
          <el-form-item label="接收人：">
            <el-input v-model="listQuery.receiveName" clearable class="filter-item" placeholder="请输入接收人姓名" />
          </el-form-item>
          <el-form-item label="手机号：">
            <el-input v-model="listQuery.receivePhone" clearable class="filter-item" placeholder="请输入接收人手机号" />
          </el-form-item>
        </el-form>
      </div>
      <div class="right">
        <el-button type="primary" @click="listSmsLog(listQuery)">查询</el-button>
        <el-button   @click="restForm">重置</el-button>
      </div>
    </div>

    <vxe-table
      v-loading="loading"
      :data="taskData"
      border="none"
      highlight-hover-row
      show-header-overflow
      show-overflow
      align="center"
      :header-cell-style="{ background: '#F7F7F8', color: '#606266' }"
          @cell-dblclick="cellDblclick"
    >
      <vxe-table-column type="seq" title="序号" width="70"/>
      <vxe-table-column title="接收人" field="receiveName" />
      <vxe-table-column title="手机号" field="receivePhone"/>
      <vxe-table-column title="内容" field="content"/>
      <vxe-table-column title="发送时间" field="sendTime" />
      <vxe-table-column title="是否发送成功" fixed="right">
        <template v-slot="{ row }">
          <el-button type="text"  v-if="row.isSuccess === '1'">成功</el-button>
          <el-button type="text" v-else @click="errorReason(row.remark)">失败</el-button>
        </template>
      </vxe-table-column>
    </vxe-table>
  </el-card>
    <vxe-pager
      class="pager"
      @page-change="changePage"
      :current-page.sync="listQuery.pageNo"
      :page-size.sync="listQuery.pageSize"
      :total="total"
      :page-sizes="[10, 30, 50, 100]"
      :layouts="['PrevJump', 'PrevPage', 'Number', 'NextPage', 'NextJump', 'Sizes', 'FullJump', 'Total']"
    >
    </vxe-pager>
  </div>
</template>

<script>
import { listSmsLog } from '@/api/log';
export default {
  name: 'User',
  data: function () {
    return {
      active: 0,
      taskData: [],
      total: 0,
      loading: true,
      listQuery: {
        pageNo: 1,
        pageSize: 10,
        receiveName: undefined,
        receivePhone: undefined
      },
    };
  },
  mounted: function () {
    this.listSmsLog();
  },
  // getTask
  methods: {
    // 列表查询
    listSmsLog() {
      this.loading = true;
      this.taskId = this.$route.query.taskId;
      listSmsLog(this.listQuery).then((data) => {
        this.taskData = data.data;
        this.total = data.total;
        this.loading = false;
      });
    },
    changePage() {
      this.listSmsLog();
    },
    errorReason(remark) {
        this.$alert(remark, '失败原因', {
          confirmButtonText: '确定',
          callback: action => {
            this.$message({
              type: 'info',
              message: `action: ${ action }`
            });
          }
        });
      },
    restForm() {
      this.listQuery = {
        pageNo: 1,
        pageSize: 10,
        receiveName: undefined,
        receivePhone: undefined
      };
      this.listSmsLog();
    },
    cellDblclick({row,rowIndex,column,columnIndex,cell},event) {
      let _this = this;
      this.$copyText(event.target.innerText).then(function() {
        _this.$message.info('复制成功');
      });
    }
  },

};
</script>

<style lang="css" scoped>
.filter-container {
  display: flex;
  justify-content: space-between;
}

.pager{
  position: fixed;
  bottom: 0;
  right: 28px;
  background-color: #FAFAFB;
  z-index: 2;
  height: 40px;
  width: calc(100% - 260px);
  }

.right >>> .el-button--primary,.el-button--default {
  padding: 10px 20px;
}

.vxe-table--render-default >>> .el-button--text{
  color: #2b7bfb;
}
.app-container >>> .vxe-table--render-default,.vxe-pager {
  font-family: PingFangSC, Arial, Helvetica, sans-serif;
} 

.left {
  flex: 8;
  display: flex;
  flex-flow: row wrap;
  margin-right: 20px;
}
.left >>> .el-form {
  width: 100%;
}
.left >>> .el-form .el-form-item {
  display: flex;
  flex-flow: row nowrap;
  width: 30%;
  margin-right: 3%;
  float: left;
  margin-bottom: 14px;
}

.left >>> .el-form .el-form-item .el-form-item__label {
  font-weight: 500;
  color: #606266;
  text-align: left;
  /* flex: 1; */
}

.left >>> .el-form .el-form-item .el-form-item__content {
  flex: 1;
  /*超出部分隐藏*/
  text-overflow: ellipsis;
  /* 超出部分显示省略号 */
  white-space: nowrap;
  /*规定段落中的文本不进行换行 */
  width: 100%;
}
.date_item {
  width: 100%;
}
.right {
  flex: 2;
  display: flex;
  flex-flow: row nowrap;
  align-items: flex-end;
  margin-right: 30px;
  margin-bottom: 30px;
}
</style>
